<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-teacher-add">
       		<input type="hidden" name="ifNew" value="true">
			<div class="form-group">	
				<label class="col-sm-2 control-label">教师工号：</label>
				<div class="col-sm-4">
					<input id="teacherNumber" name="teacherNumber" class="form-control required" type="text">
				</div>
				<label class="col-sm-2 control-label">姓名：</label>
				<div class="col-sm-4">
					<input id="name" name="name" class="form-control required" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-2 control-label">性别：</label>
				<div class="col-sm-4">
					<select id="sex" name="sex" class="form-control m-b required" th:with="type=${@dictService.selectDictData('sys_user_sex')}">
	                    <option th:each="dict : ${type}" th:text="${dict['dictLabel']}" th:value="${dict['dictValue']}"></option>
	                </select>
				</div>
				<label class="col-sm-2 control-label">联系电话：</label>
				<div class="col-sm-4">
					<input id="telphone" name="telphone" class="form-control required isPhone" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-2 control-label">所在班级：</label>
				<div class="col-sm-4">
					<input id="classNumber" name="teacherClasses.classNumber" class="form-control" type="hidden"  >
					<input id="classNumberName" class="form-control required" type="text" readonly="readonly" onclick="selectClassesTree()">
				</div>
				<label class="col-sm-2 control-label">教学科目：</label>
				<div class="col-sm-4">
					<select id="subject" name="teacherClasses.subject" class="form-control m-b required" th:with="type=${@dictService.selectDictData('teacher_subject')}">
	                    <option th:each="dict : ${type}" th:text="${dict['dictLabel']}" th:value="${dict['dictValue']}"></option>
	                </select>
				</div>
			</div>
			<div class="form-group">
				<div class="form-control-static col-sm-offset-9">
					<button type="submit" class="btn btn-primary">提交</button>
					<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "module/teacher"
		$("#form-teacher-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
				teacherNumber:{
        			required:true,
        			maxlength: 10,
                    remote: {
                        url: prefix + "/checkTeacherNumber",
                        type: "post",
                        dataType: "json",
                        data: {
                        	studentNumber: function () {
                                return $.trim($("#teacherNumber").val());
                            }
                        },
                        dataFilter: function (data, type) {
                        	if (data == "0") return true;
                            else return false;
                        }
                    }
        		},
        		name:{
        			maxlength: 10
        		}
			},
			messages: {
        		"teacherNumber":{
                	remote: "教师工号已经存在"
        		}
            },
			submitHandler: function(form) {
				$.operate.save(prefix + "/save", $('#form-teacher-add').serialize());
			}
		});
		
		/* 选择班级树 */
		function selectClassesTree(){
			var url = ctx + "module/classes/selectClassesTree";
        	$.modal.open("选择班级", url, '380', '380');
		}
	</script>
</body>
</html>
